package Main;

import java.io.*;
import java.util.ArrayList;
import java.util.List;

public class Try8_2 {
    public static void main(String[] args) throws IOException {

        String[] fileArrys = {"D:\\excel\\ganyinlan.txt","D:\\excel\\huangjie.txt","D:\\excel\\ruanjie.txt","D:\\excel\\tenglongbin.txt","D:\\excel\\xswz.txt","D:\\excel\\yf.txt","D:\\excel\\yj.txt","D:\\excel\\yqm.txt","D:\\excel\\zhw.txt","D:\\excel\\zjj.txt"};

        float swapnetCount = 0;
        float mineCount = 0;

        for (int j=0;j<fileArrys.length;j++){
            File file = new File(fileArrys[j]);
            BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
            List<String> targetList = new ArrayList<>();
            String targetLine;
            while ((targetLine=reader.readLine())!=null){
                targetList.add(targetLine);
            }
            reader.close();
            int swapnet = 0;
            int mine = 0;
            for (int i=0;i<targetList.size();i++){
                if (targetList.get(i).contains("swapnet")){
                    swapnet = swapnet + 1;
                }
                if (targetList.get(i).contains("mine")){
                    mine++;
                }
            }

            System.out.println("swapnet:"+swapnet);
            System.out.println("mine:"+mine);

            swapnetCount = swapnetCount + swapnet;
            mineCount = mine + mineCount;

        }

        System.out.println((swapnetCount)/(swapnetCount+mineCount));

    }


}
